﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CF.Tools.com.SinaSDK;

namespace CF.Member.DAL.WeiboMember
{
    public class SinaUserAuthentication
    {
        private SinaSerive oauth_ = null;
        public SinaUserAuthentication(SinaSerive oauth)
        {
            this.oauth_ = oauth;
        }

        /// <summary>
        /// 获取用户个人信息
        /// </summary>
        /// <returns></returns>
        public Dictionary<object, string> GetUserInfo()
        {
            User userT = oauth_.Users_Show();
            Dictionary<object, string> dateOut = new Dictionary<object, string>();
            dateOut.Add("Name", userT.id.ToString());
            dateOut.Add("Nick", userT.screen_name);
            dateOut.Add("Head", userT.profile_image_url);
            return dateOut;
        }
        public Dictionary<string, object> SinaAttent(int id)
        {
            Dictionary<string, object> dataout = new Dictionary<string, object>();
            try
            {
                oauth_.Friendships_Create(id);
                dataout.Add("msg", "关注成功！");
                dataout.Add("code", 1000);
                return dataout;
            }
            catch
            {
                dataout.Add("msg", "关注失败！");
                dataout.Add("code", -1);
                return dataout;
            }
        }
        public void ShareWeibo(string mesg,out int rcode,out string rmsg)
        {
           
            try
            {
                 Status st=oauth_.Statuses_Update(mesg);
                 rcode = 1000;
                 rmsg = "发布成功！";
            }
            catch
            {
                rcode = -1000;
                rmsg = "不能重复发布！";
            }
        }
    }
}
